/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$(document).ready(function(){
  result_bind(function(data){
    restoreForm('visit-edit'); 
    $('#clientName').val(data.name);
    $('#clientId').val(data.id);
  });
  
  $('#visit-detail').submit(function() {
    $.post("ajax/update.jsp", $(this).serialize(), function(data){
      console.log(data);
    });
    return false;
  });
  
  $('#visit-delete-btn').click(function(){
    var id = $('#visit-detail #id').val();
    $.post("ajax/delete.jsp", {
      id:id
    }, function(data){
      console.log(data);
    });
  });
  
  $('#visit-client-search').click(function(){
    saveForm("visit-edit");
    redirectForResult("search_client");
  });  
  
  $('#visit-client-add').click(function(){
    saveForm("visit-edit");
    redirectForResult("create_client");
  }); 
});

